package com.htfyun.eink.pw.configs;

import android.graphics.Canvas;

public class ConfigPointer {

    private static final int POINTER_HANDLED_HISTORY_MAX_COUNT_DEFAULT = 12;
    private static final float POINTER_DROP_HISTORY_XY_PIXEL_DEFAULT = 4.0f;
    private static final int INTERVAL_TIME_OF_INTERCEPT_MOVE_FOR_ON_DRAW_DEFAULT = 24;

    private float pointerDropHistoryXYPixel = POINTER_DROP_HISTORY_XY_PIXEL_DEFAULT;
    private int pointerHandledHistoryMaxCount = POINTER_HANDLED_HISTORY_MAX_COUNT_DEFAULT;

    /**
     * 在 PW 里, 仍然支持 touch 派发
     */
    private boolean touchDispatchEnabled = false;

    /**
     * 是否支持 手指 写
     */
    private boolean fingerWritable = false;

    /**
     * 当 invalidateViewWhenUp 为 true 时, 提笔时, 会调用 {@link android.view.View#invalidate()}<br>
     * 在低分辨率的屏上, 线条的锯齿会比较明显, 刷新主 View 后, 反锯齿后, 效果好很多.但是会"闪"一下.
     */
    private boolean invalidateViewWhenUp = true;

    /**
     * 配置 {@link android.graphics.Paint#setAntiAlias(boolean)} <br>
     * 如果设为 false, 锯齿比较明显, 但是在刷新 view 时, 不会闪.
     */
    private boolean antiAliasForPaint = true;

    /**
     * 在需要频繁调用 {@link android.view.View#onDraw(Canvas)} 时, 拦截 pointer move 的间隔时间<br>
     * 测试发现, 如果在处理 move 点时, 不做限制, 那么系统可能不会调用 onDraw.
     * 1. 擦除时.
     * 2. 有 float 图时;
     */
    private int intervalTimeOfInterceptMoveForOnDraw = INTERVAL_TIME_OF_INTERCEPT_MOVE_FOR_ON_DRAW_DEFAULT;

    public float getPointerDropHistoryXYPixel() {
        return pointerDropHistoryXYPixel;
    }

    public ConfigPointer setPointerDropHistoryXYPixel(float pointerDropHistoryXYPixel) {
        this.pointerDropHistoryXYPixel = pointerDropHistoryXYPixel;
        return this;
    }

    public int getPointerHandledHistoryMaxCount() {
        return pointerHandledHistoryMaxCount;
    }

    public ConfigPointer setPointerHandledHistoryMaxCount(int pointerHandledHistoryMaxCount) {
        this.pointerHandledHistoryMaxCount = pointerHandledHistoryMaxCount;
        return this;
    }

    public boolean isTouchDispatchEnabled() {
        return touchDispatchEnabled;
    }

    public ConfigPointer setTouchDispatchEnabled(boolean touchDispatchEnabled) {
        this.touchDispatchEnabled = touchDispatchEnabled;
        return this;
    }

    public boolean isFingerWritable() {
        return fingerWritable;
    }

    public ConfigPointer setFingerWritable(boolean fingerWritable) {
        this.fingerWritable = fingerWritable;
        return this;
    }

    public boolean isInvalidateViewWhenUp() {
        return invalidateViewWhenUp;
    }

    public ConfigPointer setInvalidateViewWhenUp(boolean invalidateViewWhenUp) {
        this.invalidateViewWhenUp = invalidateViewWhenUp;
        return this;
    }

    public boolean isAntiAliasForPaint() {
        return antiAliasForPaint;
    }

    public void setAntiAliasForPaint(boolean antiAliasForPaint) {
        this.antiAliasForPaint = antiAliasForPaint;
    }

    public int getIntervalTimeOfInterceptMoveForOnDraw() {
        return intervalTimeOfInterceptMoveForOnDraw;
    }

    public ConfigPointer setIntervalTimeOfInterceptMoveForOnDraw(int intervalTimeOfInterceptMoveForOnDraw) {
        this.intervalTimeOfInterceptMoveForOnDraw = intervalTimeOfInterceptMoveForOnDraw;
        return this;
    }

}
